/**
*	展会首页
**/
app.controller('gExpoIndexCtrl', ['$scope', '$state', '$stateParams', '$http', 'gConfig', 'utils',
  function($scope, $state, $stateParams, $http, gConfig, utils) {
    // 页面数据
    $scope.expoData = {
      loading: true,
      listData: [],
      end: false,
      pageSize: 10,
      pageNo:1
    }

    // 暴露到控制器
    $scope.utils = utils;
    $scope.stateParams = $stateParams;

    // 区域
    var _exhibitionSite = $stateParams.type === 'inland' ? 8 : '1,2,3,4,5,6,7';

    // 获取预警快报列表信息
    utils.get('queryExpoList', {
        random: Math.random(),
        page: 1,
        size: 15,
        mainType: '',
        name: '',
        year: '',
        exhibitionSite: _exhibitionSite
    }).success(function (rs) {
      $scope.expoData.listData = rs.data.list;
      $scope.expoData.loading = false;
    });


    $scope.loadData = function (){
      if ($scope.expoData.loading) return;
      $scope.expoData.loading = true;

      utils.get('queryExpoList', {
        random: Math.random(),
        mainType: '',
        name: '',
        year: '',
        exhibitionSite: _exhibitionSite,
          type: $stateParams.type,
          random: Math.random(),
          size: $scope.expoData.pageSize,
          page: $scope.expoData.pageNo,
          keyWords: ''
      }).success(function (rs) {
        if (rs.data.list.length) {
          $scope.expoData.listData = $scope.expoData.listData.concat(rs.data.list);
        } else {
          $scope.expoData.end = true;
        }

        $scope.expoData.loading = false;

      });
    }

    // 加载更多
    $scope.loadmoreList = function () {
      if ($scope.expoData.end) return;
      $scope.expoData.pageNo++;
      $scope.loadData();
    }

    // 获取预警快报列表信息
    // utils.get('warningIndex', {
    //   type: $stateParams.type,
    //   keyWords: ''
    // }).success(function (rs) {
    //   $scope.warningData.listData = rs.data;
    //   $scope.warningData.loading = false;
    // });

    $scope.loadData();

  }
]);
